﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

namespace Arbetsfornedringen.Pages
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Control c = this.Master.FindControl("Content");// "masterDiv"= the Id of the div.
            c.Visible = false;//to set the div to be hidden.
        }



        protected void loginButton_Click(object sender, EventArgs e)
        {
            if (userNameTextBox.Text != "" && passwordTextBox.Text != "")
            {
                string userName = userNameTextBox.Text;
                string password = passwordTextBox.Text;
                DAL.Account account;

                if (DAL.AccountDB.AuthenticateLogin(userName, password, out account))
                {
                    Session["Account"] = account;
                    Response.Redirect("~\\Pages\\Default.aspx");
                    //Response.Redirect("~\\Pages\\Register.aspx");
                }
            }
            else
            {
                lblError.Text = "Felaktiga uppgifter!";
            }
        }

        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            Server.Transfer("~\\Pages\\Register.aspx");
        }

    }
}